<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Margin</title>
    <style>
        .father{
            width: 200px;
            height: 200px;
            background-color: #f0f;
border: 1px solid red;
        }
        .son{
            /*上 右 下 左*/
            margin: auto;
            width: 100px;
            height: 100px;
            background-color: #00ff00;
        }

        .fl{
            width: 300px;
            height: 300px;
            float: left;
        }

        .bg1{
            background-color: #ff00ff;
            margin-bottom: 100px;
        }
        .bg2{
            background-color: #00ff00;
            margin-top: 100px;
        }
    </style>
</head>
<body>
<div class="father">
            <!--要用大容器的padding
            而不要用小容器的margin-->
    <div class="son">

    </div>

    <br>


</div>

<div class="fl bg1"></div>
<div class="fl bg2"></div>
</body>
</html>